﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace ProjectEuler.UI
{
    public static class GridViewService
    {
        public static readonly DependencyProperty StretchProperty;

        static GridViewService()
        {
            StretchProperty = DependencyProperty.RegisterAttached(
                "Stretch", 
                typeof(Boolean), 
                typeof(GridViewService), 
                new FrameworkPropertyMetadata(false, OnPropertyChanged));
        }

        [AttachedPropertyBrowsableForType(typeof(GridViewColumn))]
        public static Boolean GetAutoSizeToContent(GridViewColumn obj)
        {
            return (Boolean)obj.GetValue(StretchProperty);
        }

        public static void SetAutoSizeToContent(GridViewColumn obj, Boolean value)
        {
            obj.SetValue(StretchProperty, value);
        }

        private static void OnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            if (e.Property == StretchProperty)
            {
                var column = (GridViewColumn)(sender);
                var parent = LogicalTreeHelper.GetParent(column);

                
            }
        }

        
    }
}
